package com.coderlin.service.impl;

import com.coderlin.entities.Worker;
import com.coderlin.mapper.WorkerMapper;
import com.coderlin.service.WorkerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <Description> <br>
 *
 * @author Coder_Lin<br>
 * @version 1.0<br>
 * @taskId: <br>
 * @createDate 2021/07/23 16:58 <br>
 * @see com.coderlin.service.impl <br>
 */
@Service
public class WorkerServiceImpl implements WorkerService {

    @Autowired
    private WorkerMapper workerMapper;

    /**
     * 列出所有的Worker
     *
     * @return
     */
    @Override
    public List<Worker> listWorker() {
        return workerMapper.listWorker();
    }

    /**
     * 列出经过模糊查询的Worker
     *
     * @param workerName
     * @return
     */
    @Override
    public List<Worker> searchWorker(String workerName) {
        return workerMapper.searchWorker(workerName);
    }

    /**
     * 根据ID查找Worker
     *
     * @param wid
     * @return
     */
    @Override
    public Worker searchWorkerById(int wid) {
        return workerMapper.searchWorkerById(wid);
    }

    /**
     * 添加工人
     *
     * @param worker
     * @return
     */
    @Override
    public Integer addWorker(Worker worker) {
        return workerMapper.addWorker(worker);
    }

    /**
     * 根据ID删除工人
     *
     * @param wid
     * @return
     */
    @Override
    public Integer delWorkerById(int wid) {
        return workerMapper.delWorkerById(wid);
    }

    /**
     * 根据传入参数，对数据进行修改
     *
     * @param worker
     * @return
     */
    @Override
    public Integer modWorker(Worker worker) {
        return workerMapper.modWorker(worker);
    }

    /**
     * 异步更新worker工资数据
     *
     * @param wid
     * @param workerSalary
     * @return
     */
    @Override
    public Integer adjustSalary(Integer wid, Integer workerSalary) {
        return workerMapper.adjustSalary(wid,workerSalary);
    }
}
